import React,{useEffect} from 'react'
import { useDispatch ,useSelector }from 'react-redux';
import { useNavigate ,useLocation} from 'react-router-dom';
import { VALUESTYPE ,EDITADD} from '../Type/AddType.d';
import CityItem from '../Compoment/AddItem';

function EditAdd() {
    const Navigate = useNavigate();
    const Dispatch = useDispatch();
    const Location = useLocation();
    console.log(Location.state);
    let obj = Location.state as VALUESTYPE
    
    const onFinishEdit = (values:VALUESTYPE) => {
        console.log(values);
        values.id = obj.id;
        Dispatch({
            type:EDITADD,
            payload:values
        })
        Navigate('/Add')
    };
    return (
        <div className='EditAdd'>
            <CityItem onFinishEdit={onFinishEdit} obj={obj}></CityItem>
        </div>
    )
}

export default EditAdd